// 单独请求计费数据， 重构数据结构
import chargingRestructrue from './car_charging_restructrue_fn'

export default (ctx, next) =>{
    
    let { jqCheckData, syCheckData, quotations} = ctx.params;
    let chargingCode = undefined;
    
    // 判断是否存在验证码
    if( jqCheckData || syCheckData){
        chargingCode = {jqCheckData, syCheckData}
    }   

    // 重构计费数据结构
    quotations =  quotations ? chargingRestructrue(quotations) : [];
    ctx.params = {
        quotations,
        chargingCode
    };

    next();
}